(function(angular){
	'use strict';
	angular.module('fs.waf').controller('cda.classification.viewController',viewController);
	viewController.$inject = ['$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'classificationService'];
	function viewController ($scope, Constants, layoutConfig, validatorConfig, gridService, authService, classificationService){
		var ctrl = this, classificationInfo = $scope.$stateParams.params;
		
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.init = function (){
			ctrl.propClassifiInnerGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.propClassifi.tableConfigs.table, rowSelectionChanged);
			ctrl.propClassifiInnerGridOptions.data = 'vm.classification.classifiList';
			ctrl.propClassifiInnerGridOptions.enableRowHeaderSelection = false;
			
			return authService.view(classificationInfo).then(function(response){
				ctrl.classification = response.data || classificationInfo;
				ctrl.classification.siteName = classificationInfo.siteName;
				ctrl.classification.dataStatus = classificationInfo.dataStatus || 'V';
			},angular.noop());
			
			function rowSelectionChanged(eventRow, selectedRows) {
				ctrl.selectedClassifications = selectedRows;
			}
		};		
	}	
})(angular);